﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Controls;

namespace nxMgr
{
    public partial class FormSearchForWorkItem : Form
    {
        private PickWorkItemsControl ctl = null;
        public FormSearchForWorkItem(WorkItemStore store, string projname)
        {
            InitializeComponent();
            this.Text = "Search for Work Items in " + projname;
            ctl = new PickWorkItemsControl(store, false);
            ctl.Dock = DockStyle.Fill;
            ctl.PortfolioDisplayName = projname;
            this.Controls.Add(ctl);
            this.SetClientSizeCore(ctl.PreferredSize.Width, ctl.PreferredSize.Height);
            ctl.PickWorkItemsDoubleClicked += new PickWorkItemsDoubleClickedEventHandler(ctl_PickWorkItemsDoubleClicked);
        }

        void ctl_PickWorkItemsDoubleClicked(object sender, EventArgs e)
        {
            WorkItem wi = ctl.SelectedWorkItems()[0];
            using( FormWorkItem f = new FormWorkItem(wi)){
                f.ShowDialog(this);
            }
        }
    }
}
